﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using Sora.HelpSystem.Package.Pages;

namespace Sora.HelpSystem.Editor.Converters
{
    public class HelpPageTitleConverter : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var page = value as HelpPage;
            if (page == null)
                return null;
            else
            {
                if (String.IsNullOrEmpty(page.PageTitle))
                    return "{" + page.Document.DocumentBaseUri.MakeRelativeUri(page.Uri).ToString() + "}";
                else
                    return page.PageTitle;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
